package com.wanchuang.qhbb.adapter;


import android.content.Context;
import android.graphics.Color;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.wanchuang.qhbb.R;

import java.util.List;

public class AllocMachineBackAdapter extends BaseMultiItemQuickAdapter<SnAllowBean, BaseViewHolder> {
    public AllocMachineBackAdapter(Context context, List<SnAllowBean> dataList) {
        super(dataList);
        addItemType(0, R.layout.item_title_machine);
        addItemType(1, R.layout.item_alloca_machine);
    }

    @Override
    protected void convert(BaseViewHolder helper, SnAllowBean item) {

        switch (helper.getItemViewType()) {
            case 0:
                helper.setText(R.id.tv_gc_name, item.getTitle());
                break;
            case 1:
                helper.setText(R.id.tv_name, item.getItem().getGoodsName());
                if (item.getItem().getIsPolicy().equals("1") && item.getItem().getIsStock().equals("1")) {
                    helper.setVisible(R.id.tv_no_use, false)
                            .setVisible(R.id.iv_next, false)
                            .setTextColor(R.id.tv_name, Color.parseColor("#FF676E7D"));
                } else if (item.getItem().getIsPolicy().equals("0")) {
                    helper.setVisible(R.id.tv_no_use, true)
                            .setVisible(R.id.iv_next, false)
                            .setTextColor(R.id.tv_name, Color.parseColor("#FFB0B6C4"))
                            .setText(R.id.tv_no_use, "(TA该机型无政策)");
                } else if (item.getItem().getIsStock().equals("0")) {
                    helper.setVisible(R.id.tv_no_use, true)
                            .setVisible(R.id.iv_next, false)
                            .setTextColor(R.id.tv_name, Color.parseColor("#FFB0B6C4"))
                            .setText(R.id.tv_no_use, "(TA该机型无库存)");
                }
                break;
            default:
                break;
        }
    }
}